package com;

import com.mapper.WorkerMapper;
import com.pojo.Worker;
import com.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

public class WorkerTest {
   @Test
    public void findWorkerByIdTest() {
       SqlSession session = MyBatisUtils.getSqlSession();
       WorkerMapper mapper = session.getMapper(WorkerMapper.class);
       Worker worker = mapper.selectWorker(1);
       System.out.println(worker);
       session.close();
   }
   @Test
   public void insertWorkerTest() {
      SqlSession session = MyBatisUtils.getSqlSession();
      WorkerMapper mapper = session.getMapper(WorkerMapper.class);
      Worker worker = new Worker();
      worker.setId(4);
      worker.setName("赵六");
      worker.setSex("女");
      worker.setWorkerId(1005);
      int result = mapper.insertWorker(worker);
      if (result>0){
         System.out.println("添加成功");
      }else {
         System.out.println("添加失败");
      }
      System.out.println(worker);
      session.commit();
      session.close();
   }
}
